function search(key, that) {
  var param = key.trim();
  var regRule = /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g;
  if (param.match(regRule)) {
    param = param.replace(/\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g, '');
    wx.showToast({
      title: '搜素关键字含有不能被识别的字符',
      icon: 'none',
      duration: 2000
    })
    return
  }

  if (key.trim().length == 0) {
    wx.showToast({
      title: '搜素关键字不能为空',
      icon: 'none',
      duration: 2000
    })
    return;
  }
  var bookSel = that.data.bookSel;
  var bookIndex = that.data.index;
  var keyIndex = that.data.bibleKeyIndex;
  var maxNum, minNum;

  if (bookSel == '-1') {

    switch (keyIndex) {

      case '0':
        {
          minNum = 1;
          maxNum = 5;
        }
        break;
      case '1':
        {
          minNum = 17;
          maxNum = 22;
        }
        break;

      case '2':
        {
          minNum = 23;
          maxNum = 39;
        }
        break;
      case '3':
        {
          minNum = 40;
          maxNum = 43;
        }
        break;
      default:
        {
          maxNum = minNum = keyIndex - 3
        }
        break;
    }
  } else if (bookSel == 0) {
    minNum = 1;
    maxNum = 66;
  } else if (bookSel == 1) {
    minNum = 1;
    maxNum = 39;
  } else {
    minNum = 40;
    maxNum = 66;
  }

  if (key.indexOf('(') !== -1) {
    key = (key.split('(')[0]).trim();
  }
  var urlParams = util.json2Form({
    key: encodeURI(key),
    minNum: minNum,
    maxNum: maxNum,
    fromIndex: 0,
    toIndex: 500
  });
  var url0 = glo.https + '/verse/search1?' + urlParams
  wx.showLoading({
    title: "正在搜索...",
    mask: true
  });
  //console.log("连接词" + url1);
  wx.request({
    url: url0,
    header: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    method: 'GET',
    success: function(res) {
      var arrdata0 = res.data.result;
      var sumcount = res.data.sum;
      var arrdata = [];
      var pageCount = that.data.pageCount;


      // var maxNum,minNum;

      if (bookSel == '-1') {

        // switch (keyIndex){

        //   case '0':{
        //     minNum = 1;
        //     maxNum = 5;
        //   }
        //   break;
        //   case '1': {
        //     minNum = 17;
        //     maxNum = 22;
        //   }
        //     break;

        //   case '2': {
        //     minNum = 23;
        //     maxNum = 39;
        //   }
        //     break;
        //   case '3': {
        //     minNum = 40;
        //     maxNum =43;
        //   }
        //     break;
        //   default: {
        //     maxNum = minNum = keyIndex - 3
        //   }
        //     break;
        // }

        for (var i = 0; i < arrdata0.length; i++) {

          if (arrdata0[i].bookId >= minNum && arrdata0[i].bookId <= maxNum) {
            arrdata.push(arrdata0[i]);
          }
        }



      } else if (bookSel == "0") { //全部范围
        // minNum=1;
        // maxNum=66;
        arrdata = arrdata0;
      } else if (bookSel == "1") { 
        // minNum = 1;
        // maxNum = 39;
        for (var i = 0; i < arrdata0.length; i++) {
          if (arrdata0[i].bookId <= 39) {
            if (bookIndex == 0) {
              arrdata.push(arrdata0[i]);
            }
            var theBookId = parseInt(arrdata0[i].bookId);
            if (theBookId == bookIndex) {
              arrdata.push(arrdata0[i]);
            }

          }
        }

      } else { //范围
        // minNum = 40;
        // maxNum = 66;
        for (var i = 0; i < arrdata0.length; i++) {
          if (arrdata0[i].bookId > 39) {
            if (bookIndex == 0) {
              arrdata.push(arrdata0[i]);
            }
            var theBookId = parseInt(arrdata0[i].bookId);
            if (theBookId == parseInt(bookIndex) + 39) {
              console.log(theBookId);
              arrdata.push(arrdata0[i]);
            }

          }
        }
      }
      if (sumcount > 500) {
        that.setData({
          status: false
        });
        // while (arrdata.length > 100) {
        //   arrdata.pop();
        // }
      }
      console.log("结果数:" + arrdata.length);
      // var arrdata = res.data;
      var searchData = new Array();
      var markArr = [];
      for (var i = 0; i < arrdata.length; i++) {
        var content = arrdata[i].content;
        var bookId = parseInt(arrdata[i].bookId);
        var chapterId = parseInt(arrdata[i].chapterId);
        var chapterCount = 0;
        var verseId = parseInt(arrdata[i].verseId);
        var bookName = "";
        if (bookId > 39) {
          for (var j = 0; j < newbook.length; j++) {
            if (parseInt(newbook[j].bookId) == bookId) {
              bookName = newbook[j].bookName;
              chapterCount = newbook[j].chapterCount;
            }
          }
        } else {
          for (var j = 0; j < oldbook.length; j++) {
            if (parseInt(oldbook[j].bookId) == bookId) {
              bookName = oldbook[j].bookName;
              chapterCount = oldbook[j].chapterCount;
            }
          }
        }
        var verseName = bookName + " " + chapterId + ":" + verseId;
        var vid = ";#" + bookId + "-" + chapterId + "-" + verseId + "#";

        searchData[i] = new Array();
        searchData[i][0] = verseName;
        searchData[i][1] = bookId;
        searchData[i][2] = chapterId;
        searchData[i][3] = verseId;
        searchData[i][4] = bookName;
        searchData[i][5] = chapterCount;
        if (that.data.userInfo.favorite.indexOf(vid) != -1) {
          markArr[i] = 'mark';
        } else {
          markArr[i] = '';
        }
        var aaaar = content.split(key);
        for (var j = 0; j < aaaar.length; j++) {
          searchData[i][j + 6] = aaaar[j];
        }
      }
      var keyArr = that.data.historyKeyArr;
      if (keyArr.indexOf(key) == -1) {
        keyArr.unshift(key);
      }

      let ar = [];
      for (let f = 0; f < pageCount; f++) {
        ar.push(searchData[f])
      }
      console.log(searchData);

      that.setData({
        markArr: markArr,
        oData: searchData,
        searchArr: ar,
        pageCount: pageCount + 10,
        sumcount: sumcount,
        selArr: [],
        keyword: key,
        historyKeyArr: keyArr,
        historyShow: false,
        tipStrShow: false,
        toolshow: false,
        searchContShow: true
      });
      wx.setStorage({
        key: 'searchkey',
        data: keyArr,
        success: function(res) {},
        fail: function(res) {},
        complete: function(res) {},
      })

      wx.hideLoading();
    },
    fail: function(res) {
      wx.hideLoading();
      wx.showToast({
        title: '加载失败，请检查网络',
        icon: 'loading',
        duration: 1000
      })
    }

  });
}
var bibleKey = [decodeURI('%E6%91%A9%E8%A5%BF%E4%BA%94%E7%BB%8F'),decodeURI('%E8%AF%97%E7%AF%87%E7%AE%B4%E8%A8%80'),decodeURI('%E5%A4%A7%E5%B0%8F%E5%85%88%E7%9F%A5'),decodeURI('%E5%9B%9B%E7%A6%8F%E9%9F%B3%E4%B9%A6'),decodeURI('%E5%88%9B%E4%B8%96%E8%AE%B0'),decodeURI('%E5%87%BA%E5%9F%83%E5%8F%8A%E8%AE%B0'),decodeURI('%E5%88%A9%E6%9C%AA%E8%AE%B0'),decodeURI('%E6%B0%91%E6%95%B0%E8%AE%B0'),decodeURI('%E7%94%B3%E5%91%BD%E8%AE%B0'),decodeURI('%E7%BA%A6%E4%B9%A6%E4%BA%9A%E8%AE%B0'),decodeURI('%E5%A3%AB%E5%B8%88%E8%AE%B0'),decodeURI('%E8%B7%AF%E5%BE%97%E8%AE%B0'),decodeURI('%E6%92%92%E6%AF%8D%E8%80%B3%E8%AE%B0%E4%B8%8A'),decodeURI('%E6%92%92%E6%AF%8D%E8%80%B3%E8%AE%B0%E4%B8%8B'),decodeURI('%E5%88%97%E7%8E%8B%E8%AE%B0%E4%B8%8A'),decodeURI('%E5%88%97%E7%8E%8B%E8%AE%B0%E4%B8%8B'),decodeURI('%E5%8E%86%E4%BB%A3%E5%BF%97%E4%B8%8A'),decodeURI('%E5%8E%86%E4%BB%A3%E5%BF%97%E4%B8%8B'),decodeURI('%E4%BB%A5%E6%96%AF%E6%8B%89%E8%AE%B0'),decodeURI('%E5%B0%BC%E5%B8%8C%E7%B1%B3%E8%AE%B0'),decodeURI('%E4%BB%A5%E6%96%AF%E5%B8%96%E8%AE%B0'),decodeURI('%E7%BA%A6%E4%BC%AF%E8%AE%B0'),decodeURI('%E8%AF%97%E7%AF%87'),decodeURI('%E7%AE%B4%E8%A8%80'),decodeURI('%E4%BC%A0%E9%81%93%E4%B9%A6'),decodeURI('%E9%9B%85%E6%AD%8C'),decodeURI('%E4%BB%A5%E8%B5%9B%E4%BA%9A%E4%B9%A6'),decodeURI('%E8%80%B6%E5%88%A9%E7%B1%B3%E4%B9%A6'),decodeURI('%E8%80%B6%E5%88%A9%E7%B1%B3%E5%93%80%E6%AD%8C'),decodeURI('%E4%BB%A5%E8%A5%BF%E7%BB%93%E4%B9%A6'),decodeURI('%E4%BD%86%E4%BB%A5%E7%90%86%E4%B9%A6'),decodeURI('%E4%BD%95%E8%A5%BF%E9%98%BF%E4%B9%A6'),decodeURI('%E7%BA%A6%E7%8F%A5%E4%B9%A6'),decodeURI('%E9%98%BF%E6%91%A9%E5%8F%B8%E4%B9%A6'),decodeURI('%E4%BF%84%E5%B7%B4%E5%BA%95%E4%BA%9A%E4%B9%A6'),decodeURI('%E7%BA%A6%E6%8B%BF%E4%B9%A6'),decodeURI('%E5%BC%A5%E8%BF%A6%E4%B9%A6'),decodeURI('%E9%82%A3%E9%B8%BF%E4%B9%A6'),decodeURI('%E5%93%88%E5%B7%B4%E8%B0%B7%E4%B9%A6'),decodeURI('%E8%A5%BF%E7%95%AA%E9%9B%85%E4%B9%A6'),decodeURI('%E5%93%88%E8%AF%A5%E4%B9%A6'),decodeURI('%E6%92%92%E8%BF%A6%E5%88%A9%E4%BA%9A%E4%B9%A6'),decodeURI('%E7%8E%9B%E6%8B%89%E5%9F%BA%E4%B9%A6'),decodeURI('%E9%A9%AC%E5%A4%AA%E7%A6%8F%E9%9F%B3'),decodeURI('%E9%A9%AC%E5%8F%AF%E7%A6%8F%E9%9F%B3'),decodeURI('%E8%B7%AF%E5%8A%A0%E7%A6%8F%E9%9F%B3'),decodeURI('%E7%BA%A6%E7%BF%B0%E7%A6%8F%E9%9F%B3'),decodeURI('%E4%BD%BF%E5%BE%92%E8%A1%8C%E4%BC%A0'),decodeURI('%E7%BD%97%E9%A9%AC%E4%B9%A6'),decodeURI('%E5%93%A5%E6%9E%97%E5%A4%9A%E5%89%8D%E4%B9%A6'),decodeURI('%E5%93%A5%E6%9E%97%E5%A4%9A%E5%90%8E%E4%B9%A6'),decodeURI('%E5%8A%A0%E6%8B%89%E5%A4%AA%E4%B9%A6'),decodeURI('%E4%BB%A5%E5%BC%97%E6%89%80%E4%B9%A6'),decodeURI('%E8%85%93%E7%AB%8B%E6%AF%94%E4%B9%A6'),decodeURI('%E6%AD%8C%E7%BD%97%E8%A5%BF%E4%B9%A6'),decodeURI('%E5%B8%96%E6%92%92%E7%BD%97%E5%B0%BC%E8%BF%A6%E5%89%8D%E4%B9%A6'),decodeURI('%E5%B8%96%E6%92%92%E7%BD%97%E5%B0%BC%E8%BF%A6%E5%90%8E%E4%B9%A6'),decodeURI('%E6%8F%90%E6%91%A9%E5%A4%AA%E5%89%8D%E4%B9%A6'),decodeURI('%E6%8F%90%E6%91%A9%E5%A4%AA%E5%90%8E%E4%B9%A6'),decodeURI('%E6%8F%90%E5%A4%9A%E4%B9%A6'),decodeURI('%E8%85%93%E5%88%A9%E9%97%A8%E4%B9%A6'),decodeURI('%E5%B8%8C%E4%BC%AF%E6%9D%A5%E4%B9%A6'),decodeURI('%E9%9B%85%E5%90%84%E4%B9%A6'),decodeURI('%E5%BD%BC%E5%BE%97%E5%89%8D%E4%B9%A6'),decodeURI('%E5%BD%BC%E5%BE%97%E5%90%8E%E4%B9%A6'),decodeURI('%E7%BA%A6%E7%BF%B0%E5%A3%B9%E4%B9%A6'),decodeURI('%E7%BA%A6%E7%BF%B0%E8%B4%B0%E4%B9%A6'),decodeURI('%E7%BA%A6%E7%BF%B0%E5%8F%81%E4%B9%A6'),decodeURI('%E7%8A%B9%E5%A4%A7%E4%B9%A6'),decodeURI('%E5%90%AF%E7%A4%BA%E5%BD%95')];


var util = require('../../utils/util.js')
var bibleData = require('../../utils/bible.js')
var glo = require('../../utils/global.js')
var oldbook = "";
var newbook = "";
var app = getApp();
var lastTapDiffTime = 0;
Page({
  data: {
    userInfo: [],
    selArr: [], //选择搜索后的
    selUrlshow: false,
    markArr: [],
    searchArr: [],
    keyword: '',
    keyvalue: '',
    array: [],
    bookSel: "0",
    bookSelKey: "指定范围",
    bookSelClass: decodeURI("%E6%95%B4%E6%9C%AC%E5%9C%A3%E7%BB%8F"),
    index: 3,
    status: true,
    historyKeyArr: [],
    bibleKeyIndex: 3,
    bibleKey: bibleKey,
    historyShow: false,
    tipStrShow: true,
    searchContShow: false,
    toolshow: false,
    notbetext: decodeURI("%E7%AC%94%E8%AE%B0"),
    zbsj: decodeURI('%E6%95%B4%E6%9C%AC%E5%9C%A3%E7%BB%8F'),
    jytab: decodeURI('%E6%97%A7%E7%BA%A6'),
    xytab: decodeURI('%E6%96%B0%E7%BA%A6'),
    versionStr: decodeURI('%E5%92%8C%E5%90%88%E6%9C%AC'),
    tipStr: decodeURI('%E6%88%91%E5%8F%88%E5%91%8A%E8%AF%89%E4%BD%A0%E4%BB%AC%EF%BC%9A%E4%BD%A0%E4%BB%AC%E7%A5%88%E6%B1%82%EF%BC%8C%E5%B0%B1%E7%BB%99%E4%BD%A0%E4%BB%AC%EF%BC%9B%E5%AF%BB%E6%89%BE%EF%BC%8C%E5%B0%B1%E5%AF%BB%E8%A7%81%EF%BC%9B%E5%8F%A9%E9%97%A8%EF%BC%8C%E5%B0%B1%E7%BB%99%E4%BD%A0%E4%BB%AC%E5%BC%80%E9%97%A8%E3%80%82'),
    oData: [],
    pageCount: 10,
    noMore: false,
    screenH: 0
  },
  lower: function(e) {
    var that = this,
      oData = this.data.oData,
      dataLength = oData.length,
      pCount = this.data.pageCount,
      newArr = [];

    for (let i = 0; i < pCount; i++) {
      if (oData[i] !== undefined) {
        newArr.push(oData[i]);
      } else {
        that.setData({
          noMore: true
        });
        break;
      }　
    }
    this.setData({
      searchArr: newArr,
      pageCount: pCount + 10
    });
  },
  back: function() {
    wx.navigateBack({

    });
  },
  tapcancel: function() {
    this.setData({
      toolshow: false,
      selArr: []
    });
  },
  openTool: function(e) {
    var bool = true;
    var i = e.currentTarget.dataset.index;
    var selArr = this.data.selArr;

    if (selArr[i]) {
      selArr[i] = false;
    } else {
      selArr[i] = true;
    }
    if (selArr.indexOf(true) == -1) {
      bool = false;
    }

    var selOneBool = selArr.filter(function(item) {
      return item == true;
    }).length === 1;

    this.setData({
      toolshow: bool,
      selArr: selArr,
      selUrlshow: selOneBool
    });
  },
  clearKeyArr: function() {
    this.setData({
      historyKeyArr: [],
      historyShow: false,
      tipStrShow: true
    });
    wx.setStorage({
      key: 'searchkey',
      data: [],
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  keywordInputEvent: function(e) {
    var val = e.detail.value.trim();
    if (val.length == 0) {
      this.setData({
        historyShow: true,
        tipStrShow: false,
        searchContShow: false
      });
    }
    this.setData({
      keyvalue: e.detail.value
    });

  },

  toastHide: function(event) {
    console.log("触发bindchange，隐藏toast")
    this.setData({
      status: true
    })
  },
  searchWord: function(e) {
    var key = e.target.dataset.key;
    search(key, this);
    this.setData({
      keyvalue: key
    });
  },
  searchbind: function(e) {
    var key = this.data.keyvalue;
    if (key == undefined) {
      return;
    }
    search(key, this);
  },
  catalogUrl: function(e) {
    var index = this.data.selArr.lastIndexOf(true);
    var data = this.data.searchArr[index];
    var that = this;
    var bookId = data[1];
    var chapterId = data[2];
    var bookName = data[4];
    var chapterCount = data[5];
    var verseid = data[3];
    var content = "";
    var keyid = "CH" + "-" + bookId + "-" + chapterId;

    wx.getStorage({
      key: "bk" + bookId,
      success: function(res) {
        wx.showLoading({
          title: "正在加载...",
          mask: true
        });
        var bookData = res.data;
        for (var i = 0; i < bookData.length; i++) {
          if (chapterId == bookData[i].chapterId) {
            content = bookData[i].content;
            console.log("缓存读取" + bookName + "第" + chapterId + "章");
            wx.navigateTo({
              url: '../content/content' + '?bookName=' + bookName + '&chapterId=' + chapterId + '&chapterCount=' + chapterCount + '&bookId=' + bookId + '&content=' + content + '&lid=' + verseid + '&from=0',
              success: function(res) {
                console.log(verseid)
                wx.hideLoading();
                that.tapcancel();
                // success
              },
              fail: function() {
                wx.hideLoading();
                // fail
              }
            })
          }
        }
      },
      fail: function() {
        wx.showLoading({
          title: "首次加载该卷",
          mask: true
        });
        wx.request({
          url: glo.https + '/chapter/list_bookid?bookId=' + bookId,
          method: 'GET',
          success: function(res) {
            wx.setStorage({ //添加缓存
              key: "bk" + bookId,
              data: res.data
            });
            var bookData = res.data;
            for (var i = 0; i < bookData.length; i++) {
              if (chapterId == bookData[i].chapterId) {
                content = bookData[i].content;
                console.log("缓存读取" + bookName + "第" + chapterId + "章");
                wx.navigateTo({
                  url: '../content/content' + '?bookName=' + bookName + '&chapterId=' + chapterId + '&chapterCount=' + chapterCount + '&bookId=' + bookId + '&content=' + content + '&lid=' + verseid + '&from=0',
                  success: function(res) {
                    wx.hideLoading();
                    // success
                  },
                  fail: function() {
                    wx.hideLoading();
                    wx.showToast({
                      title: '加载失败，请检查网络',
                      icon: 'loading',
                      duration: 1000
                    })
                    // fail
                  }
                })
              }
            }
          }
        })
      }
    });
  },

  radioChange: function(e) {
    var str = decodeURI('%E6%95%B4%E6%9C%AC%E5%9C%A3%E7%BB%8F');
    var v = e.detail.value
    var array1 = ["全部"];
    if (v == "0") {
      array1 = ["全部"];
    } else if (v == "1") {
      for (var i = 0; i < oldbook.length; i++) {
        array1.push(oldbook[i].bookName);
      }
    } else {
      for (var i = 0; i < newbook.length; i++) {
        array1.push(newbook[i].bookName);
      }
    }
    switch (parseInt(v)) {
      case 0:
        str = decodeURI('%E6%95%B4%E6%9C%AC%E5%9C%A3%E7%BB%8F');
        break;
      case 1:
        str = decodeURI('%E6%97%A7%E7%BA%A6');
        break;
      case 2:
        str = decodeURI('%E6%96%B0%E7%BA%A6');
        break;
      case 3:
        str = "指定范围";
        break;
    }

    this.setData({
      bookSel: v,
      array: array1,
      bookSelKey: "指定范围",
      bookSelClass:str,
      index: 0,
      scrollTop: 'top01',
      pageCount: 10,
      noMore: false
    });
    this.searchbind();

  },
  bindPickerChange: function(e) {
    this.setData({
      bibleKeyIndex: e.detail.value,
      bookSel: -1,
      bookSelKey: bibleKey[e.detail.value],
      bookSelClass: bibleKey[e.detail.value],
      scrollTop: 'top01',
      pageCount: 10,
      noMore: false
    });

    this.searchbind();
  },
  clearStr: function(e) {
    console.log(e);
    this.setData({
      keyvalue: '',
      keyword: '',
      pageCount: 10
    });
  },

  tap_mark: function(e) {
    var selArr = this.data.selArr;
    var data = this.data.searchArr;
    var markArr = this.data.markArr;
    var that = this;
    var favorite = that.data.userInfo.favorite;

    for (var i = 0; i < selArr.length; i++) {
      if (selArr[i]) {
        var vid = ";#" + data[i][1] + "-" + data[i][2] + "-" + data[i][3] + "#";
        var sindex = favorite.indexOf(vid);
        if (sindex == -1) {
          favorite = favorite + vid;
          markArr[i] = 'mark';
        } else {
          if (favorite.indexOf(vid) > -1) {
            favorite = favorite.replace(vid, "");
            markArr[i] = '';
          }
        }
      }
    }
    this.setData({
      toolshow: false,
      selArr: [],
      markArr: markArr
    });
    wx.request({
      url: glo.https + '/person/fav_update',
      data: {
        favorite: favorite,
        userid: that.data.userInfo.userId
      },
      success: function(res2) {
        that.data.userInfo.favorite = favorite;
        app.setUserInfo(that.data.userInfo);
      }
    });

  },
  tap_notbe: function(e) {
    var selContents = [];
    var selIndexs = [];
    var selChapters = [];
    var selArr = this.data.selArr;
    var data = this.data.searchArr;
    var keyword = this.data.keyword;

    for (var i = 0; i < selArr.length; i++) {
      if (selArr[i]) {
        var str = data[i].slice(6).join(keyword);
        selContents.push(str);
        selIndexs.push(data[i][0]);
        selChapters.push(data[i][1] + '|' + data[i][2] + ':' + data[i][3]);
      }
    }
    this.setData({
      toolshow: false,
      selArr: []
    });
    wx.navigateTo({
      url: '../editnotbe/editnotbe?content=' + JSON.stringify(selContents) + '&index=' + JSON.stringify(selIndexs) + '&chapter=' + JSON.stringify(selChapters) + "&edit=0",
    })
  },
  changeScreenLight: function(e) {
    wx.setScreenBrightness({
      value: parseFloat(e.detail.value).toFixed(1)
    })
  },
  tap_copy: function(e) {
    var that = this;
    var selArr = this.data.selArr;
    var data = this.data.searchArr;
    var keyword = this.data.keyword;
    var str = '';
    for (var i = 0; i < selArr.length; i++) {
      if (selArr[i]) {
        str += data[i].slice(6).join(keyword) + '(' + data[i][0] + ')';
      }
    }
    console.log(str)
    wx.setClipboardData({
      data: str,
      success: function(res) {
        wx.getClipboardData({
          success: function(res) {
            that.setData({
              toolshow: false,
              selArr: []
            });
          }
        })
      }
    })
  },
  /**
   * 用户点击右上角
   */
  onShareAppMessage: function() {
    return {
      title: '这是我分'+'享给您的' + decodeURI('%E5%9C%A3%E7%BB%8F%E7%BB%8F%E6%96%87'),
      desc: '微信小程序版本' + decodeURI('%E5%9C%A3%E7%BB%8F'),
      path: '/pages/index/index'
    }
  },

  onLoad: function() {
    var that = this;
    var screenH = 0;
    oldbook = bibleData.oldbooks;
    newbook = bibleData.newbooks;
    wx.getSystemInfo({
      success: function(res) {
        screenH = res.screenHeight
      }
    });
    this.setData({
      logs: (wx.getStorageSync('logs') || []).map(function(log) {
        return util.formatTime(new Date(log))
      }),
      screenH: screenH
    });

    //显示关键字搜索历史
    if (this.data.historyKeyArr.length > 0) {
      this.setData({
        historyShow: true,
        tipStrShow: false
      });
    }

    app.getUserInfo(function(userInfo) {
      that.setData({
        userInfo: userInfo,
        favorite: userInfo.favorite
      });
    });
    wx.getStorage({
      key: 'searchkey',
      success: function(res) {
        var arr = res.data;
        that.setData({
          historyKeyArr: arr
        });

        if (arr.length > 0) {
          that.setData({
            historyShow: true,
            tipStrShow: false,
            searchContShow: false
          });
        }
      }
    });

  },
  delWord:function(e){
    var key = e.target.dataset.key;
    var keyArr = this.data.historyKeyArr;
    var index = keyArr.indexOf(key);
    keyArr.splice(index,1);
    wx.setStorage({
      key: 'searchkey',
      data: keyArr,
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
    var historyShow=true;
    var tipStrShow=false;
    if(keyArr.length==0){
      historyShow=false;
      tipStrShow=true;
    }
    this.setData({ historyKeyArr: keyArr, historyShow: historyShow, tipStrShow: tipStrShow});
  },
  onShow: function() {
   
  }
})